package com.elder.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson2.JSONObject;
import com.elder.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.elder.common.annotation.Log;
import com.elder.common.core.controller.BaseController;
import com.elder.common.core.domain.AjaxResult;
import com.elder.common.enums.BusinessType;
import com.elder.business.domain.ElderlyApartmentBeds;
import com.elder.business.service.IElderlyApartmentBedsService;
import com.elder.common.utils.poi.ExcelUtil;
import com.elder.common.core.page.TableDataInfo;

/**
 * 床位信息Controller
 * 
 * @author elder
 * @date 2023-11-26
 */
@RestController
@RequestMapping("/business/beds")
public class ElderlyApartmentBedsController extends BaseController
{
    @Autowired
    private IElderlyApartmentBedsService elderlyApartmentBedsService;

    /**
     * 查询床位信息列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(String elderName,Integer bedStatus,String roomCode,Integer pageNum,Integer pageSize) {
        return elderlyApartmentBedsService.getElderlyApartmentBedsList(elderName,bedStatus,roomCode,pageNum,pageSize);
    }

    /**
     * 导出床位信息列表
     */
//    @PreAuthorize("@ss.hasPermi('business:beds:export')")
//    @Log(title = "床位信息", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, ElderlyApartmentBeds elderlyApartmentBeds)
//    {
//        List<ElderlyApartmentBeds> list = elderlyApartmentBedsService.selectElderlyApartmentBedsList(elderlyApartmentBeds);
//        ExcelUtil<ElderlyApartmentBeds> util = new ExcelUtil<ElderlyApartmentBeds>(ElderlyApartmentBeds.class);
//        util.exportExcel(response, list, "床位信息数据");
//    }

    /**
     * 获取床位信息详细信息
     */
    @Anonymous
    @RequestMapping("/getBedInfo")
    public String getInfo(@RequestParam("Id") Long Id)
    {
        return elderlyApartmentBedsService.selectElderlyApartmentBedsById(Id).toJSONString();
    }

    /**
     * 新增床位信息
     */
    @Anonymous
    @Log(title = "床位信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElderlyApartmentBeds elderlyApartmentBeds)
    {
        return toAjax(elderlyApartmentBedsService.insertElderlyApartmentBeds(elderlyApartmentBeds));
    }

    /**
     * 修改床位信息
     */
    @Anonymous
    @Log(title = "床位信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElderlyApartmentBeds elderlyApartmentBeds)
    {
        return toAjax(elderlyApartmentBedsService.updateElderlyApartmentBeds(elderlyApartmentBeds));
    }

    /**
     * 删除床位信息
     */
    @Anonymous
    @Log(title = "床位信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(elderlyApartmentBedsService.deleteElderlyApartmentBedsByIds(ids));
    }
}
